package com.showcai.util;

import com.showcai.tools.ToolsBase;

import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Properties;

public class GetProperties extends ToolsBase {
	private static Properties config = null;

	static {
		InputStream in = GetProperties.class.getClassLoader()
				.getResourceAsStream("/conf/config.properties");
		config = new Properties();
		try {
		
			config.load(in);
		
			in.close();
		} catch (IOException e) {
		
			System.out.println("No AreaPhone.properties defined error");
		}
	}

	
	public static String readValue(String key) {
		// Properties props = new Properties();
		try {
			String value = config.getProperty(key);
			return value;
		} catch (Exception e) {
			e.printStackTrace();
					return null;
		}
	}

	public static void readAllProperties() {
		try {

			Enumeration en = config.propertyNames();
			while (en.hasMoreElements()) {
				String key = (String) en.nextElement();
				String Property = config.getProperty(key);
				System.out.println(key + Property);
			}
		} catch (Exception e) {
			e.printStackTrace();
			System.err.println("ConfigInfoError" + e.toString());
		}
	}
}

